package org.yjc.controller;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yjc.custom.JqgridParam;
import org.yjc.custom.JqgridUtils;
import org.yjc.entity.Log;
import org.yjc.service.LogService;

@Controller
@RequestMapping(value="/log")
public class LogController {
	@Autowired
	private LogService logservice;
	
	@RequestMapping(value="logmain")
	public String log() {
		return "log/log";
		
	}
	
	@RequestMapping(value="/list",method=RequestMethod.POST)
	@ResponseBody
	public Object list(JqgridParam param) {
		Pageable pageable = param.buildPageable();
		Page<Log> page = null;
		if(!param.getSearch()) {
			page=logservice.findAll(pageable);
		}else {
			page=logservice.findAll(param.buildSpec(),pageable);
		}
		HashMap<String, Object> result = JqgridUtils.getPageResult(page);
		return result;
	}
}
